/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __X_HOOK_TABLE_H__
#define __X_HOOK_TABLE_H__

/* includes (standard library, system) ---------------------------------------*/
#include <stdint.h>
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
/* includes (local) ----------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* defines -------------------------------------------------------------------*/
/* typedefs ------------------------------------------------------------------*/
/* macro ---------------------------------------------------------------------*/

#define hook_table_foreach(idx, table, slots)                                                      \
    for (idx = 0; idx < slots && table[idx] != NULL; idx++)

/* inlines -------------------------------------------------------------------*/
/* externs -------------------------------------------------------------------*/

extern int hook_table_add(uintptr_t *hooks, int slots, uintptr_t pfn);
extern int hook_table_del(uintptr_t *hooks, int slots, uintptr_t pfn);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __X_HOOK_TABLE_H__ */
